package com.zhang.thread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestRun {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable = new MyCallable();
        MyRunnable myRunnable = new MyRunnable();
        MyThread myThread = new MyThread();
        Thread thread1 = new Thread(myThread,"myThread");
        Thread thread2 = new Thread(myRunnable,"myRunnable");
        FutureTask<String> futureTask = new FutureTask<>(myCallable);
        Thread thread3 = new Thread(futureTask);
        String s = futureTask.get();
        thread3.start();
        thread1.run();
        System.out.println("s = " + s);
        thread1.start();
        thread2.start();
    }
}
